import json
import requests
import sys
from returnExcult import *

def func(data):
    return reTest.test(data)




if __name__ == '__main__':
    #从外面拿到参数
    jsonStr = sys.argv[1]
    #python3 xxx.py 参数 需要转两次才能是字典
    std = json.loads(jsonStr)
    varStd=json.loads(std)
    #参数构建
    result={"apiName":"身份证二要素验证","secret":"abfa041cc7a84419957ca69421bb0680","shortName":"br"}
    result["name"]=varStd["name"]
    result["id"]=varStd["id"]
    #参数json化
    str = json.dumps(result)
    # 调用数据网关接口 得到结果
    host = 'http://zebra.sit.com/service-interface-gateway/api/invoke'
    requests.DEFAULT_RETRIES = 10# 增加重试连接次数
    s = requests.session()
    s.keep_alive = False
    header_dict = {"Content-Type": "application/json; charset=utf8",
                   "User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36",
                   "Connection":"close"}
    r = s.post(host, data=str, headers=header_dict,timeout=None,verify=False)
    # 请求完成后 关闭连接
    r.close()
    json_data = ''
    if (r.ok):
        json_data = r.json()
    print(func(json_data))